import createG2 from 'g2-react';
import React from 'react';

export default class HigherChart extends React.Component<any, any> {
    private Chart;
    private chart;
    constructor(props, ...others) {
        super(props, ...others);
        this.Chart = createG2(chart => {
            this.chart = chart;
            chart.line().position('time*price').color('name').shape(props.shape).size(2);
            chart.render();
        });
    }

    componentWillReceiveProps(nextProps) {
        if (nextProps.shape !== this.props.shape) {
            this.chart.clear();
            this.chart.line().position('time*price').color('name').shape(nextProps.shape).size(2);
            this.chart.render();
        }
    }

    render() {
        return (<this.Chart {...this.props} />);
    }
};
